﻿using B.S.Ingredients.APIRead.Application.Command.Over;
using B.S.Ingredients.Domain;
using B.S.Ingredients.ErrorCode;
using B.S.Ingredients.Infartructrue.Interfaces;
using MediatR;

namespace B.S.Ingredients.APIRead.Application.CommandHandler.OverHandler
{
    public class OverTimeCreateCommandHandler : IRequestHandler<OverTimeCreateCommand, APIResult<int>>
    {
        public OverTimeCreateCommandHandler(IBaseRepository<OvertimeClass> OverRepository)
        {
            this.OverRepository = OverRepository;
        }

        public IBaseRepository<OvertimeClass> OverRepository { get; }

        public async Task<APIResult<int>> Handle(OverTimeCreateCommand request, CancellationToken cancellationToken)
        {
            
            var path =await OverRepository.CreateAsync(request.Data);

            return new APIResult<int>
            {
                Code = ResultCode.success,
                Mag = "",
                Data = path
            };
        }
    }
}
